package com.liuzh.deviceinfo.appinfo.appanalyze;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.FrameLayout;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.e;
import androidx.recyclerview.widget.RecyclerView.z;
import c.h.a.x.s.d;
import c.h.a.x.s.h;
import c.h.a.x.s.i;
import c.h.a.x.s.j;
import c.h.a.x.s.l;
import c.h.a.x.s.n;
import com.liuzh.deviceinfo.DeviceInfoApp;
import com.liuzh.deviceinfo.base.BaseActivity;
import com.liuzh.deviceinfo.pro.ProActivity;
import java.util.Objects;

public class AppsAnalyzeActivity extends BaseActivity {
    public static final /* synthetic */ int D = 0;
    public View A;
    public int B = 1;
    public boolean C = false;
    public TextView q;
    public View r;
    public RecyclerView s;
    public c t;
    public AppsAnalyzeActivity u = this;
    public n v;
    public int w = 2;
    public Spinner x;
    public FrameLayout y;
    public AppsAnalyzeResultDetailView z;

    public class a implements OnItemSelectedListener {
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
            AppsAnalyzeActivity appsAnalyzeActivity = AppsAnalyzeActivity.this;
            appsAnalyzeActivity.w = i;
            appsAnalyzeActivity.B();
        }

        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    public class b extends c.h.b.a.a.b {
        public void b() {
            c.f.a.a.a.a.z("ad_app_ana");
        }

        public void c(String str) {
            n nVar = AppsAnalyzeActivity.this.v;
            if (!(nVar == null || nVar.a.isEmpty())) {
                int i = 0;
                while (i < AppsAnalyzeActivity.this.v.a.size()) {
                    if (((i) AppsAnalyzeActivity.this.v.a.get(i)).c == -1) {
                        break;
                    }
                    i++;
                }
                i = -1;
                if (i != -1) {
                    AppsAnalyzeActivity.this.v.a.remove(i);
                    AppsAnalyzeActivity.this.t.e(i);
                }
            }
            ProActivity.G(AppsAnalyzeActivity.this);
        }

        public void d(String str) {
            c.f.a.a.a.a.x("ad_app_ana", str);
        }

        public void e(View view) {
            AppsAnalyzeActivity appsAnalyzeActivity = AppsAnalyzeActivity.this;
            appsAnalyzeActivity.A = view;
            n nVar = appsAnalyzeActivity.v;
            if (nVar != null && !nVar.a.isEmpty()) {
                AppsAnalyzeActivity appsAnalyzeActivity2 = AppsAnalyzeActivity.this;
                appsAnalyzeActivity2.v.a.add(appsAnalyzeActivity2.B, new i(-1));
                appsAnalyzeActivity2 = AppsAnalyzeActivity.this;
                c cVar = appsAnalyzeActivity2.t;
                cVar.a.e(appsAnalyzeActivity2.B, 1);
            }
        }
    }

    public class c extends e<z> {
        public LayoutInflater c;

        public c() {
            this.c = LayoutInflater.from(AppsAnalyzeActivity.this);
        }

        public int a() {
            n nVar = AppsAnalyzeActivity.this.v;
            if (nVar == null) {
                return 0;
            }
            return nVar.a.size();
        }

        public int c(int i) {
            return ((i) AppsAnalyzeActivity.this.v.a.get(i)).c;
        }

        public void f(z zVar, int i) {
            i iVar = (i) AppsAnalyzeActivity.this.v.a.get(i);
            if (zVar instanceof l) {
                l lVar = (l) zVar;
                Objects.requireNonNull(lVar);
                switch (iVar.c) {
                    case 1:
                        lVar.v.setText(2131690439);
                        lVar.w.setText(2131690441);
                        lVar.w(iVar);
                        break;
                    case 2:
                        lVar.v.setText(2131690071);
                        lVar.w.setText(2131690073);
                        lVar.w(iVar);
                        break;
                    case 3:
                        lVar.v.setText(2131690121);
                        lVar.w.setText(2131690123);
                        lVar.w(iVar);
                        break;
                    case 4:
                        lVar.v.setText(2131689566);
                        lVar.w.setText(2131690015);
                        lVar.w(iVar);
                        break;
                    case 5:
                        lVar.v.setText(2131690007);
                        lVar.w.setText(2131690010);
                        lVar.w(iVar);
                        break;
                    case 6:
                        lVar.v.setText(2131690358);
                        lVar.w.setText(2131690360);
                        lVar.w(iVar);
                        break;
                }
                zVar.a.setOnClickListener(new c.h.a.x.s.b(this, iVar));
            } else if (zVar instanceof j) {
                j jVar = (j) zVar;
                n nVar = AppsAnalyzeActivity.this.v;
                Objects.requireNonNull(jVar);
                c.h.b.b.a aVar = nVar.b;
                jVar.t.setText(DeviceInfoApp.c.getString(2131689622, new Object[]{Integer.valueOf(aVar.d)}));
                jVar.u.setText(String.valueOf(aVar.b));
                jVar.v.setText(String.valueOf(aVar.c));
                jVar.w.setText(String.valueOf(aVar.e));
                jVar.x.setText(String.valueOf(aVar.f));
                jVar.y.setText(c.h.a.m0.j.f(aVar.g));
            } else if (zVar instanceof h) {
                h hVar = (h) zVar;
                View view = AppsAnalyzeActivity.this.A;
                Objects.requireNonNull(hVar);
                if (view != null && view.getParent() == null) {
                    if (hVar.a.getVisibility() != 0) {
                        hVar.a.setVisibility(0);
                    }
                    hVar.t.addView(view);
                }
            }
        }

        public z g(ViewGroup viewGroup, int i) {
            if (i == -1) {
                return new h(this.c.inflate(2131492971, viewGroup, false));
            }
            if (i == 0) {
                return new j(this.c.inflate(2131492981, viewGroup, false));
            }
            return new l(this.c.inflate(2131492980, viewGroup, false));
        }
    }

    public final void A() {
        if (!c.h.a.f0.j.d.i()) {
            c.h.a.m0.i iVar = c.h.a.m0.i.a;
            iVar = c.h.a.m0.i.a;
            if (!c.h.a.m0.i.b()) {
                c.f.a.a.a.a.y("ad_app_ana");
                c.h.b.a.a.c.a(this, c.h.a.u.a.h, new b());
            }
        }
    }

    public final void B() {
        if (!this.C) {
            this.C = true;
            this.x.setEnabled(false);
            AsyncTask.execute(new d(this));
        }
    }

    public void onBackPressed() {
        if (this.y.getChildCount() != 0) {
            this.y.removeAllViews();
        } else {
            this.e.a();
        }
    }

    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        z();
        setContentView(2131492892);
        this.y = (FrameLayout) findViewById(2131296505);
        Spinner spinner = (Spinner) findViewById(2131296979);
        this.x = spinner;
        spinner.setSelection(this.w);
        this.x.setOnItemSelectedListener(new a());
        this.q = (TextView) findViewById(2131297278);
        this.r = findViewById(2131296703);
        this.s = (RecyclerView) findViewById(2131296829);
        c cVar = new c();
        this.t = cVar;
        this.s.setAdapter(cVar);
        B();
        A();
        c.h.a.v.a.b.c("app_ana_show", null);
    }
}
